﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Slja.Model;
using Slja.BLL;
using Slja.Utility;
using FrameWork.Components;
using FrameWork.Interface;

namespace FrameWork.web.Web.UC
{
    public partial class BasicInfo : OrderSectionBase
    {
        //public OrderExtModel _Order;
        ///// <summary>
        ///// 订单实体类
        ///// </summary>
        //public OrderExtModel Order
        //{
        //    get { return _Order; }
        //    set { _Order = value; }
        //}
        //OpRightState _OpRight;
        ///// <summary>
        ///// 操作权限
        ///// </summary>
        //public OpRightState OpRight
        //{
        //    get { return _OpRight; }
        //    set { _OpRight = value; }
        //}
        //protected void Page_Load(object sender, EventArgs e)
        //{
        //    if (!IsPostBack)
        //    {
        //        LoadData();
        //    }
        //}
        public override void SaveData()
        {
            throw new NotImplementedException();
        }
        protected override OpRightState GetOpRight()
        {
            //下单后，“基本信息”皆不可编辑
            if ((Order.SaleStateLog & (int)SaleState.None) == (int)SaleState.None//尚未下单
                ||Order.Enum_BackState == SaleState.NewOrder                    //退回到下单人
                )
            {
                return (ControlUsage == DisplayUsage.DefaultDisplay) ? OpRightState.Editable : OpRightState.Readonly;
            }
            return OpRightState.Readonly;
        }
        protected override void LoadData()
        {
            if (Order == null)
            { return; }
            tlbAddress.Text = Order.Address;
            tlbAgentCorp.Text = Order.AgentClientName;
            tlbAgentSalesman.Text = Order.AgentSaleMan;
            tlbCity.Text = Order.CityName;
            tlbClient.Text = Order.ClientName;
            tlbPlanner.Text = Order.PlanMakerName;
            tlbPrjend.Text = Order.PlanEndDate.HasValue?Order.PlanEndDate.Value.ToString("yyyy-MM-dd"):"";
            tlbPrjID.Text = Order.PrjID;
            tlbPrjManger.Text = Order.ManagerUserName;
            tlbPrjName.Text = Order.PrjName;
            tlbPrjstart.Text = Order.PlanStartDate.HasValue?Order.PlanStartDate.Value.ToString("yyyy-MM-dd"):"";
            tlbProductType.Text = Order.ProductType;
            tlbRegion.Text = Order.Region;
            tlbSalesman.Text = Order.SalemanName;
            tlbSaleType.Text = Order.SaleType.HasValue?((SaleType)Order.SaleType).ToDescription():"";
            tlbSaleVolume.Text = Order.SaleVolume;
            tlbShopLev.Text = Order.ShopLev;
            tlbShopLinkman.Text = Order.ShopLinkMan;
            tlbShopLinkmanTel.Text = Order.ShopLinkManTel;
            tlbShopName.Text = Order.ShopName;
            tlbShopPromotor.Text = Order.ShopPromotor;
            tlbShopSquare.Text = Order.ShopSquare;
            tlbShopTLCode.Text = Order.TLCode;            

        }
    }
}